#ifndef mainwindow_H
#define mainwindow_H

#include <QMainWindow>

#include "SerialPort.h"
#include "qled.h"

#include <QTimer>
#include <QByteArray>
#include <QString>
#include <QKeyEvent>


namespace Ui {
    class mainwindow;
}

class mainwindow : public QMainWindow
{
    Q_OBJECT

    public:
        explicit mainwindow(QWidget *parent = 0);
        ~mainwindow();

    private:
        Ui::mainwindow *ui;
        SerialPort *sp;
        bool portOpen;
        int writeCommand(char);
        QTimer *timerRead;
        void keyPressEvent(QKeyEvent *);
        void keyReleaseEvent(QKeyEvent *);
    private slots:
        void portOn();
        void portOff();
        void portFailed();
        void dataListener();
        void on_actionOuvrir_triggered(bool checked=false);
        void on_actionFermer_triggered(bool checked=false);
        void on_actionQuitter_triggered(bool checked=false);
        void on_btSend_clicked();
        int on_btAvancer_pressed();
        int on_btReculer_pressed();
        int on_btGauche_pressed();
        int on_btDroite_pressed();
        int on_btAvancer_released();
        int on_btReculer_released();
        int on_btGauche_released();
        int on_btDroite_released();
        int on_btSuiviLigne_clicked();
        int readStatus();

    signals:
        void keyLeftPressed();
        void keyRightPressed();
        void keyUpPressed();
        void keyDownPressed();
        void keyLeftReleased();
        void keyRightReleased();
        void keyUpReleased();
        void keyDownReleased();
};

#endif // mainwindow_H
